#ifndef XBUFFER_H
#define XBUFFER_H

//FIFO buffer

typedef struct struct_buffer
{
	unsigned char *pData;			//address to the beginning of a buffer
	unsigned short bufSize;			//size in bytes
	unsigned short bytesCount;		//how many bytes within buffer are taken
	unsigned short iData;		    //index to the byte to read

} xBuffer;

void            bufferInit(xBuffer* buffer,  unsigned char* start,  unsigned short size);
unsigned short  bufferRead(xBuffer* buffer,  unsigned char* dest,   unsigned short size);
unsigned short  bufferWrite(xBuffer* buffer, unsigned char* source, unsigned short size);
void            bufferFlush(xBuffer* buffer);
unsigned short  bufferGetCount(xBuffer* buffer);
unsigned short  bufferGetFreeBytes(xBuffer* buffer);

#endif
